<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8" />
	<meta http-equiv="content-Type" content="text/html;charset=utf-8">
	<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />

	<meta name="description" content="同乡烩后台管理系统" />
	<title>同乡烩后台管理系统</title>
	<link rel="stylesheet" href="css/bootstrap.min.css">
	<link rel="stylesheet" href="css/reset.css" />
	<link rel="stylesheet" href="css/main.css" />
	<link rel="stylesheet" href="css/list.css" />
	<script type="text/javascript" src="js/jquery-3.4.1.js"></script>
	<script src="js/bootstrap.min.js"></script>
	<script type="text/javascript">
		var currentpage;
		$(function () {
			var body_height = $(document).height();
			$(".main").css("height", body_height + "px")
			$("#caipin").empty();

			$.ajax({
				type:"get",
				url:"dishes/findallDishes.do?pageNum=1",
				dataType:"json",
				success:function (data){
					$.each(data,function (i,n){
						$("#caipin").append("<div class='section section2'><div class='margin-right-container-nav margin-right-container-nav2'>" +
								"<img src='images/"+n.image+"'>" +
								"</div>" +
								"<div class='margin-right-container-nav margin-right-container-nav2'>"+n.name+"</div>" +
								"<div class='margin-right-container-nav margin-right-container-nav2'>"+n.sales+"</div>" +
								"<div class='margin-right-container-nav margin-right-container-nav2'>"+n.price+"</div>" +
								"<div class='margin-right-container-nav margin-right-container-nav2'><a id='change' onclick='modifyDi("+n.foodid+")'>修改</a>/<a id='remove' onclick='deleteDi("+n.foodid+")'>删除</a></div>" +
								"<div class='clear'></div></div>")
					})
				}
			})

		})
		function deleteDi(obj) {
			if(confirm("是否删除")){
				$.ajax({
					type: "get",
					url: "dishes/deleteDish.do",
					data:{
						"id":obj
					},
					dataType: "json",
					success:function (data){
						if(data.result==1){
							alert("删除成功");
							window.location.reload();
						}else {
							alert("删除失败，请检查网络");
						}
					}
				})
				return true;
			}else {
				return false;
			}
		}
		function fenye(obj){
			currentpage=obj;
			$("#caipin").empty();
			$.ajax({
				type:"get",
				url:"dishes/findallDishes.do",
				data:{
					"pageNum":obj
				},
				dataType:"json",
				success:function (data){
					$.each(data,function (i,n){
						$("#caipin").append("<div class='section section2'><div class='margin-right-container-nav margin-right-container-nav2'>" +
								"<img src='images/"+n.image+"'>" +
								"</div>" +
								"<div class='margin-right-container-nav margin-right-container-nav2'>"+n.name+"</div>" +
								"<div class='margin-right-container-nav margin-right-container-nav2'>"+n.sales+"</div>" +
								"<div class='margin-right-container-nav margin-right-container-nav2'>"+n.price+"</div>" +
								"<div class='margin-right-container-nav margin-right-container-nav2'><a id='change' onclick='modifyDi("+n.foodid+")'>修改</a>/<a id='remove' onclick='deleteDi("+n.foodid+")'>删除</a></div>" +
								"<div class='clear'></div></div>")
					})
				}
			})
		}
	</script>
</head>
<!-- 菜品列表 -->
<body>
<!-- 固定 -->
<div class="main">
	<div class="main-left main-left2">
		<div class="main-left-header">同乡烩后台管理系统</div>
		<div class="main-left-nav">

			<div class="main-left-navs main-left-manage navs-active">
				<p class="nav-name">商品管理</p>
				<div class="navs  navs-first" onclick="window.location.href='dish-list.html'">菜品列表</div>
				<div class="navs" onclick="window.location.href='data-list.html'">原材料列表</div>
				<div class="navs" onclick="window.location.href='dish-add.html'">菜品添加</div>
				<div class="navs" onclick="window.location.href='data-add.html'">原材料添加</div>
			</div>





		</div>
	</div>


	<div class="main-left"></div>

	<!-- 操作 -->
	<div class="main-right">
		<div class="main-right-header"></div>
		<div class="main-right-navs">
			<a href="index-manage.html">管理首页</a><a class="split">/</a><a>菜品管理</a><a>/</a><a>菜品列表</a>
			<!-- 搜索模块 -->
			<div class="search">

				<input type="text" value="" placeholder="请输入关键词">

				<button> </button>

			</div>
		</div>


		<div class="margin-right-container">
			<div class="section section1">
				<div class="margin-right-container-nav">图片</div>
				<div class="margin-right-container-nav">菜品名称</div>
				<div class="margin-right-container-nav">月销量</div>
				<div class="margin-right-container-nav">价格</div>
				<div class="margin-right-container-nav">操作</div>
				<div class="clear"></div>
			</div>

			<div id="caipin">
			<div class="section  section2">
				<div class="margin-right-container-nav margin-right-container-nav2">
					<img src="images/head.jpg" />
				</div>

				<div class="margin-right-container-nav margin-right-container-nav2">菜名</div>
				<div class="margin-right-container-nav margin-right-container-nav2">菜类</div>
				<div class="margin-right-container-nav margin-right-container-nav2">999</div>
				<div class="margin-right-container-nav margin-right-container-nav2"><a id="change">修改</a>/<a
						id="remove">删除</a></div>
				<div class="clear"></div>
			</div>
			</div>

		</div>
		<div id="pagination">
		<nav aria-label="Page navigation">
			<ul class="pagination">
				<li>
					<a href="#" aria-label="Previous">
						<span aria-hidden="true" id="previous">上一页</span>
					</a>
				</li>
				<li><a href="#" onclick="fenye(1)">1</a></li>
				<li><a href="#" onclick="fenye(2)">2</a></li>
				<li><a href="#" onclick="fenye(3)">3</a></li>
				<li><a href="#" onclick="fenye(4)">4</a></li>
				<li><a href="#" onclick="fenye(5)">5</a></li>
				<li>
					<a href="#" aria-label="Next">
						<span aria-hidden="true" id="next">下一页</span>
					</a>
				</li>
				<span id="txt"></span>
			</ul>

		</nav>
		</div>
	</div>

</div>
</body>
</html>
